﻿using UnityEngine;
using System.Collections;

public class BackdropMove : MonoBehaviour {

	GameObject backdrops;
	public float MoveTime = 2f;
	float MoveStartTime = 2f;
	float endYTransVal = -1.348083f;
	float startYTransVal = -6.57f;
	float endScale = 1f;
	float startScale = 0.66f;

	// Use this for initialization
	void Start () {
		this.backdrops = GameObject.Find ("Backdrops");
		this.MoveStartTime = this.MoveTime;
	}
	
	// Update is called once per frame
	void Update () {
		MoveTime -= Time.deltaTime;
		if (MoveTime < 0f) {
			MoveTime = 0f;
		}
		if (MoveTime >= 0f) {
			float yVal = Mathf.Lerp (startYTransVal, endYTransVal, 1.0f - MoveTime / MoveStartTime);
			float scale = Mathf.Lerp (startScale, endScale, 1.0f - MoveTime / MoveStartTime);
			Vector3 pos = backdrops.transform.position;
			pos.y = yVal;
			backdrops.transform.position = pos;
			Vector3 lScale = backdrops.transform.localScale;
			lScale.x = lScale.y = scale;
			backdrops.transform.localScale = lScale;
		}
	}
}
